<template>
  <div v-swiper:mySwiper="swiperOption" style="height:100%;width:100%;">
    <div class="swiper-wrapper">
      <div class="swiper-slide">
        <el-image
          src="/static/img/xmzs/17项目.jpg"
          fit="fit"
          style="position:relative;height:100%;width:100%"
        />
      </div>
      <div class="swiper-slide">
        <el-image
          src="/static/img/xmzs/17项目2.jpg"
          fit="fit"
          style="position:relative;height:100%;width:100%"
        />
      </div>
      <div class="swiper-slide">
        <el-image
          src="/static/img/xmzs/17项目3.jpg"
          fit="fit"
          style="position:relative;height:100%;width:100%"
        />
      </div>
    </div>
    <div class="swiper-pagination"></div>
  </div>
</template>

<script>
import { Swiper, SwiperSlide, directive } from "vue-awesome-swiper";

export default {
  el: "#app",
  components: {
    Swiper,
    SwiperSlide
  },
  directives: {
    swiper: directive
  },
  data() {
    return {
      startTime: 0,
      endTime: 0,
      swiperOption: {
        pagination: {
          el: ".swiper-pagination"
        },

        direction: "vertical"
        // ...
      }
    };
  },
  mounted() {
    window.onmousewheel = this.srollWheel.bind(this);
   

    //this.mySwiper.slideTo(3, 1000, false)
  },
  methods: {
    // 鼠标滚动
    srollWheel(event) {
      
      this.startTime = new Date().getTime();
      // mousewheel事件中的 “event.wheelDelta” 属性值：返回的如果是正值说明滚轮是向上滚动
      // DOMMouseScroll事件中的 “event.detail” 属性值：返回的如果是负值说明滚轮是向上滚动
      const delta = event.deltaY;
      // 如果当前滚动开始时间和上次滚动结束时间的差值小于1.5s，则不执行翻页动作，这样做是为了实现类似节流的效果
      if (this.startTime - this.endTime > 500) {
        if (delta > 0) {
          // 向下滚动
         this.mySwiper.slideNext(300)
        } else {
          // 向上滚动
          this.mySwiper.slidePrev(300);
        }
        // 本次翻页结束，记录结束时间，用于下次判断
        this.endTime = new Date().getTime();
      }
    },
    // Listener event
    slide(data) {
      console.log(data);
    },
    onTap(data) {
      console.log(data);
    },
    onInit(data) {
      console.log(data);
    }
  }
};
</script>

<style scoped>
.swiper-pagination-bullet {
  width: 15px;
  height: 15px;
  background-color: wheat;
  border-radius: 50%;
  -moz-border-radius: 50%;
  -webkit-border-radius: 50%;
  margin-bottom: 5px;
  cursor: pointer;
}

.container {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  bottom: 0;
}

.a {
  position: relative;
  height: 100%;
  left: 0;
  right: 0;
  bottom: 0;
  top: 0;
  width: 100%;
  background-image: url(../../assets/img/xmzs/17项目.jpg);
}
</style>
